import axios from 'axios'
import qs from 'qs'
// axios.defaults.baseURL = config.host
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
axios.interceptors.request.use(function (o) {
  return o
}, function (error) {
  return Promise.reject(error)
})
axios.interceptors.response.use(function (response) {
  return response.data
}, function (error) {
  return Promise.reject(error)
})
export default {
  request: axios.request,
  get: function (url, map) {
    return axios.get(url, {params: map})
  },
  delete: function (url, map) {
    return axios.delete(url, {params: map})
  },
  head: axios.head,
  post: function (url, map) {
    return axios.post(url, qs.stringify(map))
  },
  put: function (url, map) {
    return axios.put(url, qs.stringify(map))
  },
  patch: function (url, map) {
    return axios.patch(url, qs.stringify(map))
  }
}
